﻿using System.Collections.Generic;
using System.Web.Mvc;
using IterationLife.Extensions.ControllerBase;
using Util.Domains.Contexts;
using Util.Ui.Results;
using Util.Ui.Trees;
using Util;

namespace IterationLife.PlatformBackEnd.WebSite.Controllers
{
    /// <summary>
    /// 首页控制器
    /// </summary>
    public class HomeController : PermissionControllerBase
    {

        /// <summary>
        /// 获取首页
        /// </summary>
        public ActionResult Index()
        {
            if (ApplicationContext.User.UserId.IsEmpty())
                return RedirectToAction("Login", "Authentication");
            else
                return View();
        }

        /// <summary>
        /// 获取菜单
        /// </summary>
        public ActionResult GetModules()
        {
            List<TreeNode> treeNodes = new List<TreeNode>()
            {
                new TreeNode()
                {
                    Id = "0",
                    ParentId = string.Empty,
                    Text = "系统",
                    Attributes =  new { url = "#" }
                },
                new TreeNode()
                {
                    Id = "0.1",
                    ParentId = "0",
                    Text = "行政区域",
                    Attributes =  new { url = "/Systems/District" }
                },

                new TreeNode()
                {
                    Id = "1",
                    ParentId = string.Empty,
                    Text = "足球",
                    Attributes =  new { url = "#" }
                },
                new TreeNode()
                {
                    Id = "1.1",
                    ParentId = "1",
                    Text = "在线教育",
                    Attributes =  new { url = "#" }
                },
                new TreeNode()
                {
                    Id = "1.1.1",
                    ParentId = "1.1",
                    Text = "课程分类管理",
                    Attributes =  new { url = "/FootballTeachings/CourseCategory" }
                },
                new TreeNode()
                {
                    Id = "1.1.2",
                    ParentId = "1.1",
                    Text = "球员位置管理",
                    Attributes =  new { url = "/FootballTeachings/PlayerPosition" }
                },
                new TreeNode()
                {
                    Id = "1.1.3",
                    ParentId = "1.1",
                    Text = "课程管理",
                    Attributes =  new { url = "/FootballTeachings/Course" }
                },

                new TreeNode()
                {
                    Id = "2",
                    ParentId = string.Empty,
                    Text = "内容资源",
                    Attributes =  new { url = "#" }
                },
                new TreeNode()
                {
                    Id = "2.1",
                    ParentId = "2",
                    Text = "分类管理",
                    Attributes =  new { url = "/ContentResources/Category" }
                },
                new TreeNode()
                {
                    Id = "2.2",
                    ParentId = "2",
                    Text = "内容管理",
                    Attributes =  new { url = "/ContentResources/Content" }
                },
            };
            return new TreeResult(treeNodes).GetResult();
        }

    }
}
